<?php


namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
	
    public function index(){
		//调试
    	$info=C('LOGIN_EXP');
    	trace($info,'调试','ERR');
		
    	//分类
    	$data=M('category');
    	$cate=$data->where(array('pid'=>0))->select();
		foreach ($cate as $k => $v) {
			$cate[$k]['sub']=$data->where(array('pid'=>$v['cid']))->select();
		}
				
    	$this->assign('cate',$cate);//左侧分类
		
		
		$this->ask_list();//首页待解决问题
		$this->reward_list();//高分未解决
    	$this->display();
    }
	/*待解决问题列表*/
	public function ask_list(){
		$askListWhere['solve']=0;
		$askListWhere['gold']=array('LT',5);
		$askList=M('ask')->field('asid,content,answer,cid')->where($askListWhere)->order('time desc')->limit(5)->select();
		$this->assign('askList',$askList);
	}
	/*高分悬赏问题*/
	public function reward_list(){
		$rewardListWhere['solve']=0;
		$rewardListWhere['gold']=array('EGT',5);
		$rewardList=M('ask')->field('asid,content,answer,gold,cid')->where($rewardListWhere)->order('time desc,gold desc')->limit(5)->select();
		$this->assign('rewardList',$rewardList);
	}
}



